#!/bin/bash
string="Four score and seven years ago"
echo Experiments with the string: \"$string\"

n=$(expr length "$string")
echo The string has $n characters.

# Search for characters
qchars=txp   # query characters
index=$(expr index "$string" "$qchars" )
if [ $index -gt 0 ]
then
   echo A character in \"$qchars\" was found in the string at position $index.
else
   echo None of the characters \"$qchars\" were found in the string.
fi

# Search for a word starting with an upper-case letter
w1=$(expr "$string" : '^\([A-Z][a-z]*\)')
echo The first word starting with an upper-case letter is $w1
n1=$(expr "$string" : '^[A-Z][a-z]*')
echo The length of the first word is $n1
